<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" />
        <meta name="format-detection" content="telephone=no" />
        <title>{$name}</title>
        <link href="__PUBLIC__/css/style.css" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
        <script type="text/javascript" src="{:U('js/url')}"></script>
    </head>

    <body class="egg_body">
        <div class="egg_box">
            <div class="egg_main">
                <div class="egg_main_title"></div>
                <php>if(empty($msg)){</php>
                <ul class="eggList">
                    <p class="hammer" id="hammer">锤子</p>
                    <p class="resultTip" id="resultTip"><b id="result"></b></p>
                    <li><sup></sup></li>
                    <li><sup></sup></li>
                    <li><sup></sup></li>
                </ul>
                <php>}else{
                    echo '<p>'.$msg.'</p>';
                    }</php>
            </div>
        </div>
        <div class="min_box">
            <div class="set_main">
                <div class="set_box">
                    <div class="set_box_layer"><a href="{:U('/my_prize')}">查看中奖记录</a></div>
                    <p>{$prize}</p>
                </div>
            </div>
            <div class="event_main">
                <div class="event_box">
                    <p>{$explain}</p>
                </div>
            </div>
        </div>
        <php>if(empty($msg)){</php>
        <script type="text/javascript">
            function eggClick(obj) {
                var _this = obj;
                $.getJSON(app_url + "/choujiang/zajindan_make/id/<php>echo $id;</php>", function(res) {
                    if (_this.hasClass("curr")) {
                        alert("蛋都碎了，别砸了！刷新再来.");
                        return false;
                    }
                    //_this.unbind('click');
                    $(".hammer").css({"top": _this.position().top - 55, "left": _this.position().left + 125});
                    $(".hammer").animate({
                        "top": _this.position().top - 20,
                        "left": _this.position().left + 125
                    }, 30, function() {
                        _this.addClass("curr"); //蛋碎效果
                        _this.find("sup").show(); //金花四溅
                        $(".hammer").hide();
                        $('.resultTip').css({display: 'block', top: '100px', opacity: 0}).animate({top: '20px', opacity: 0.7}, 300, function() {
                            if (res.msg == 1) {
                                $("#result").html(res.prize);
                            } else {
                                $("#result").html("很遗憾,您没能中奖!");
                            }
                        });
                    }
                    );
                });
            }

            $(".eggList li").click(function() {
                $(this).children("span").hide();
                eggClick($(this));
            });

            $(".eggList li").hover(function() {
                var posL = $(this).position().left + $(this).width();
                $("#hammer").show().css('left', posL);
            })
        </script>
        <php>}</php>
    </body>
</html>
